package com.sh.data.engine.domain.integration.api.taskconfig.model.param;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;
import java.util.List;

/**
 * @author : changkong
 * @date : 2022/3/14
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TaskConfigParam {
    // 目标数据源
    private Long targetDsId;

    // 目标数据源类型
    private String targetDsType;
    // 目标表
    private String targetTableName;

    // 替换策略
    private Integer dataReplaceRuleId;
    // 同步前清空历史记录
    private Integer isTruncate;

    // 失败记录阈值
    private Integer errorNumLimit;

    // 字段映射方式
    private Integer fieldMapType;
    // 字段映射
    private List<FieldMapping> fieldMappings;

    private List<TargetField> targetFields;

    private List<PartitionField> partitions;

    private Integer status;

    /*生效开始时间*/
    private Date effectiveDateStart;

    /*生效结束时间*/
    private Date effectiveDateEnd;

    /*调度周期 0-月 1-周 2-天 3-小时 4-分钟*/
    private Integer cycle;

    /*执行开始时间的小时*/
    private String startTimeHour;

    /*执行开始时间的分钟*/
    private String startTimeMin;

    /*执行结束时间的小时*/
    private String endTimeHour;

    /*执行结束时间的分钟*/
    private String endTimeMin;

    /*
     * 月、周为执行日期 ，小时、分钟为执行间隔
     */
    private String execPoint;

    /*跨周期依赖 0-不依赖上一周期 1-等待上一周期结束*/
    private Integer cycleDependence;

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class FieldMapping {
        private String sourceField;

        private String sourceFieldType;

        private Integer isSourceFieldPk;

        private String targetField;

        private String targetFieldType;

        private Integer isTargetFieldPk;

        private String targetComment;
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class TargetField {
        private String fieldName;

        private String fieldType;
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class PartitionField {

        private String fieldName;

        private String fieldValue;
    }
}
